package ace.module.captcha.core.impl.api.impl;

import ace.cmp.core.model.R;
import ace.module.captcha.api.CaptchaImageApi;
import ace.module.captcha.api.model.dto.CaptchaImageDto;
import ace.module.captcha.api.model.input.CaptchaCreateInput;
import ace.module.captcha.core.impl.service.CaptchaImageService;
import ace.module.common.api.annotation.ApiLocalPriority;
import jakarta.annotation.Priority;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

/**
 * .
 * @author Caspar
 *
 */
@ApiLocalPriority
@AllArgsConstructor
@Component
public class CaptchaImageApiImpl implements CaptchaImageApi {

  private final CaptchaImageService captchaImageService;

  @Override
  public R<CaptchaImageDto> createBase64Data(CaptchaCreateInput captchaCreateInput) {
    CaptchaImageDto resultDTO = captchaImageService.createBase64(captchaCreateInput.getCaptchaAppId());
    return R.ok(resultDTO);
  }

  @Override
  public R<Void> verify(Long captchaItemId, String code) {
    this.captchaImageService.verify(captchaItemId, code);
    return R.ok();
  }
}
